package com.cjm.algorithm.tree;

import com.cjm.algorithm.TreeNode;

public class Ti700 {
    public static void main(String[] args) {

    }

    public TreeNode searchBST(TreeNode root, int val) {
        return findTarget700(root, val);
    }

    private TreeNode findTarget700(TreeNode root, int target) {
        if (root == null) return null;
        if (root.val == target) {
            return root;
        }
        TreeNode left = findTarget700(root.left, target);
        if (left != null) {
            return left;
        }
        return findTarget700(root.right, target);
    }
}
